<?php
class tahminsModel extends CI_Model
{
     function __construct()
     {
         
        $this->load->database();
    $this->load->library('session');
     }
 
    function index(){
        $this->load->library('session');
        if(!$this->session->userdata('validated')){
            redirect('login/loginn');
        }
    }
    
    function addTahm($fname,$fext){
        if(!$this->session->userdata('validated')){
            redirect('login/loginn');
        }else{
        if(strlen($this->input->post('sharetext'))>0){
            $shTxt = $this->input->post('sharetext');
        }else{
            $shTxt = '';
        }
        $new_file_data =array(
    	'tahminser_id' => $this->session->userdata('id'),
        'tahminser_uname' => $this->session->userdata('kadi'),
    	'tarih' => date('d/m/y H:i'),
    	'oran' => $this->input->post('rate'),
    	'begeni_pos' => 0,
    	'begeni_neg' => 0,
        'resim' => $fname.''.$fext,
    	'mini_res' => $fname.'_thumb'.$fext,
    	'yazi' => $shTxt,
    	'durum' => 0,
    	'oy' => 0,
    	'canli_mi' => 0,
        'sistem_mi' => 0,
        'onay' => 0,
        'admin' => 0
    	);
    	$insert = $this->db->insert('kuponlar',$new_file_data);
    	return $insert;
        }
    }
    
    function addTahmNoImg(){
        if(!$this->session->userdata('validated')){
            redirect('login/loginn');
        }else{
        $fname = '';
        $new_file_data =array(
    	'tahminser_id' => $this->session->userdata('id'),
        'tahminser_uname' => $this->session->userdata('kadi'),
    	'tarih' => date('d/m/y H:i'),
    	'oran' => $this->input->post('rate'),
    	'begeni_pos' => 0,
    	'begeni_neg' => 0,
        'resim' => $fname,
    	'mini_res' => $fname,
    	'yazi' => $this->input->post('sharetext'),
    	'durum' => 0,
    	'oy' => 0,
    	'canli_mi' => 0,
        'sistem_mi' => 0,
        'onay' => 0,
        'admin' => 0
    	);
    	$insert = $this->db->insert('kuponlar',$new_file_data);
    	return $insert;
        }
    }

}
?>
